package tech.aistar.corejava.day14.homework;

import java.io.*;

/**
 * Created by 豆梦寒 on 2019/8/2.
 */
public class Test04 {
  public static void main(String[] args) throws Exception {
      BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("src\\tech\\aistar\\corejava\\day14\\homework\\calcCharNum.txt")));
      int[] count  = new int[26];
      int[] COUNT  = new int[26];

      char[] c = new char[1];
      int len = br.read(c);
      while(len!=-1) {

          if(c[0]<='Z'&&c[0]>='A') {
              int number = c[0];
              COUNT[number-65]++;
          }
          if(c[0]<='z'&&c[0]>='a') {
              int number = c[0];
              count[number-97]++;
          }
          len = br.read(c);
      }
      Print(count, COUNT);
      //System.out.print("\nb.txt文件读取完毕！");
      br.close();

  }
    public static void Print(int[] count,int[] COUNT) {
        for(int i=0;i<26;i++) {
            if(count[i]>0) {
                char lowerCase = (char)(i+97);
                System.out.print(lowerCase+"("+count[i]+")");
            }
            if(COUNT[i]>0) {
                char upperCase = (char)(i+65);
                System.out.print(upperCase+"("+COUNT[i]+")");
            }
        }

    }

}
